<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="user"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/user/userCompanySave?id=${n.id }&user.id=${n.user.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
                 <label class="col-sm-2 control-label">用户名</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.username" ${empty n.id ? '' : 'readonly' } value="${n.user.username }">
                 </div>
             </div>	
             <c:if test="${empty n.id}">
             <div class="form-group">
                 <label class="col-sm-2 control-label">密码</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.password" value="${n.user.password }">
                 </div>
             </div>	
             </c:if>
              <div class="form-group">
                 <label class="col-sm-2 control-label">公司名称</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="name" value="${n.name }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">公司Logo</label>
                 <div class="col-sm-10">
                 	<input type="hidden" name="headImage" id="headImage" value="${n.headImage }" />
                 	<div class="my-images" single="true" images="${n.headImage }" id="headImage1" field="headImage">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">省</label>
                 <div class="col-sm-10">
					<select name="user.province.id" class="form-control" id="provinceId">
						<c:forEach items="${provinces }" var="p">
						<option value="${p.id }" ${n.user.province.id eq p.id ? 'selected' : '' }>${p.name }</option>
						</c:forEach>
					</select>						                 	
                 </div>
                 
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">城市</label>
                 <div class="col-sm-10">
                 	<select name="user.city.id" class="form-control" id="cityId">
                 		<c:if test="${not empty(n.user.city.id) }">
                 		<option value="${n.user.city.id }">${n.user.city.name }</option>
                 		</c:if>
					</select>	
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">地区</label>
                 <div class="col-sm-10">
                 	<select name="user.district.id" class="form-control" id="districtId">
	                 	<c:if test="${not empty(n.user.district.id) }">
	                 		<option value="${n.user.district.id }">${n.user.district.name }</option>
                 		</c:if>
					</select>
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">公司注册地址</label>
                 <div class="col-sm-10">
            		<input type="text" class="form-control" name="registerAddress" value="${n.registerAddress }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">联系人</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.contactName" value="${n.user.contactName }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">联系人电话</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.mobile" value="${n.user.mobile }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">qq</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.QQ" value="${n.user.QQ}">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">公司办公地址</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="officeAddress" value="${n.officeAddress }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">销售类型</label>
                 <div class="col-sm-10">
                 	 ${enum:detail('CompanySalesType', 'salesType', n.salesType) }
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">公司网址</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="webSite" value="${n.webSite }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">公司人数</label>
                 <div class="col-sm-10">
                 	 ${enum:detail('CompanyQuantity', 'quantity', n.quantity) }
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">公司行业</label>
                 <div class="col-sm-10">
                 	 ${enum:detail('CompanyIndustry', 'industry', n.industry) }
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">公司性质</label>
                 <div class="col-sm-10">
                 	 ${enum:detail('CompanyNature', 'nature', n.nature) }
                 </div>
             </div>
             <div class="form-group">
                <label class="col-sm-2 control-label">公司简介</label>
                <div class="col-sm-10">
                	 <textarea rows="" cols="" class="form-control" name="details">${n.details }</textarea>
                </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-2 control-label">备注</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="remark" value="${n.remark }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">证件上传</label>
                 <div class="col-sm-10">
		            <input type="hidden" name="images" id="images" value="${n.images }" />
                 	<div class="my-images" single="false" images="${n.images }" id="image2" field="images">
                 	</div>
                 </div>
             </div>
		</form>
</div>

<%@include file="/common/foot.jsp" %>

<script>
$('#provinceId').change(function() {
	var provinceId = $(this).val();
	$('#cityId').html('');
	$('#districtId').html('');
	if (provinceId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?provinceId=" + provinceId,
			dataType: "json",
			success: function(array) {
				$('#cityId').append('<option value="">城市</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#cityId').append(option);	
				}
			}
		});
	}
	
});

$('#cityId').change(function() {
	var cityId = $(this).val();
	$('#districtId').html('');
	if (cityId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?cityId=" + cityId,
			dataType: "json",
			success: function(array) {
				$('#districtId').append('<option value="">地区</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#districtId').append(option);	
				}
			}
		});
	}
	load_filter_user();
});

$('#districtId').change(function() {
	load_filter_user();
});

$(document).ready(function() {
	init_images('image2');
	init_images('headImage1');
});
</script>
</body>
</html>
